package com.hm.ipay.schedule;

import com.hm.ipay.service.GameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *  游戏开奖定时任务
 */
@Component
public class AutoGameLottery {

    @Autowired
    GameService gameService;

    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");


    //@Scheduled(fixedDelay = 15000)
    //@Scheduled(cron="0 0 0/1 * * ?")  // 每小时执行
    @Scheduled(cron="0 0/15 * * * ?")  // 每15分钟执行
    public void reportCurrentTime() {
        System.out.println("AutoGameLottery 现在时间：" + dateFormat.format(new Date()));
        gameService.gameLottery();
    }
}
